n = 4, k = 3

function solution(n, k) {
    let x = 1
    let sum = 0
    while (n > 0) {
        sum = sum + k * x
        x++
        n--
    }
    return sum
}
console.log(solution(n, k));
